﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class autoForm_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ConfigTable cTab = ConfigTable.GetDefaultConfig("news");

            foreach (Control c in AutoForm.GetFormContrls<ConfigColumns>(cTab.Columns[1]))
            {
                //this.Panel1.Controls.Add(c);
            }

            foreach (Control c in AutoForm.GetFormContrls<ConfigTable>(cTab))
            {
                this.Panel1.Controls.Add(c);
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ConfigTable cTab = ConfigTable.GetDefaultConfig("news");
        cTab = AutoForm.SetValue<ConfigTable>(cTab);
        //ConfigColumns cCol = AutoForm.SetValue<ConfigColumns>(cTab.Columns[1]);

        //foreach (Control c in AutoForm.GetFormContrls<ConfigColumns>(cCol))
        {
            //this.Panel1.Controls.Add(c);
        }

        foreach (Control c in AutoForm.GetFormContrls<ConfigTable>(cTab))
        {
            this.Panel1.Controls.Add(c);
        }
    }
}
